home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / ooo2wordml_border.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  11KB  |  162 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml_border.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:05:22 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  37.     <!-- multiple usage: get size, type, color of table-cell, paragraph, and page borders. -->
  38.     <xsl:template name="get-border-size">
  39.         <xsl:param name="border"/>
  40.         <xsl:param name="border-line-width"/>
  41.         <xsl:choose>
  42.             <xsl:when test="$border = 'none' or $border = 'hidden'">
  43.                 <xsl:text>none;0</xsl:text>
  44.             </xsl:when>
  45.             <xsl:otherwise>
  46.                 <xsl:variable name="border-value">
  47.                     <xsl:call-template name="convert2cm">
  48.                         <xsl:with-param name="value" select="$border"/>
  49.                     </xsl:call-template>
  50.                 </xsl:variable>
  51.                 <xsl:variable name="border-style">
  52.                     <xsl:choose>
  53.                         <xsl:when test="contains($border,'solid')">solid</xsl:when>
  54.                         <xsl:when test="contains($border,'double')">double</xsl:when>
  55.                         <xsl:otherwise>none</xsl:otherwise>
  56.                     </xsl:choose>
  57.                 </xsl:variable>
  58.                 <!-- MS word and SO wirter borders Mapping
  59.                 MS word Borders                         SO borders
  60.                 w:val="single" w:sz="0"                     0.05pt(0.002cm);solid
  61.                 w:val="single" w:sz="12"                     1.00pt(0.035cm);solid
  62.                 w:val="single" w:sz="18"                      2.50pt(0.088cm);solid
  63.                 w:val="single" w:sz="36"                         4.00pt(0.141cm);solid
  64.                 w:val="single" w:sz="48"                          5.00pt(0.176cm);solid
  65.                 w:val="double" w:sz="2"                          1.10pt(0.039cm);double
  66.                 w:val="double" w:sz="6"                          2.60pt(0.092cm);double
  67.                 w:val="thin-thick-small-gap" w:sz="12"                  3.00pt(0.105cm);double
  68.                 w:val="thin-thick-large-gap" w:sz="18"                3.55pt(0.125cm);double
  69.                 w:val="thick-thin-medium-gap" w:sz="24"         4.50pt(0.158cm);double
  70.                 w:val="thin-thick-medium-gap" w:sz="24"         5.05pt(0.178cm);double
  71.                 w:val="thin-thick-small-gap" w:sz="24"            6.00pt(0.211cm);double
  72.                 w:val="thin-thick-medium-gap" w:sz="36            " 6.55pt(0.231cm);double
  73.                 w:val="double" w:sz="18"                         7.50pt(0.264cm);double
  74.                 w:val="thin-thick-medium-gap" w:sz="48"         9.00pt(0.317cm);double;style:border-line-width="0.088cm 0.088cm 0.141cm"
  75.                 w:val="double" w:sz="24"                        9.00pt(0.317cm);double;style:border-line-width="0.141cm 0.088cm 0.088cm"
  76.                 we adjust the criteria by adding about 1/2 range of this current criteria and next criteria.  Gary. Yang -->
  77.                 <xsl:variable name="microsoft-border-style-size">
  78.                     <xsl:choose>
  79.                         <xsl:when test=" $border-style = 'solid'">
  80.                             <xsl:choose>
  81.                                 <xsl:when test="$border-value <= 0.018">single;0</xsl:when>
  82.                                 <xsl:when test="$border-value <= 0.055">single;12</xsl:when>
  83.                                 <xsl:when test="$border-value <= 0.110">single;18</xsl:when>
  84.                                 <xsl:when test="$border-value <= 0.155">single;36</xsl:when>
  85.                                 <xsl:when test="$border-value <= 0.198">single;48</xsl:when>
  86.                                 <xsl:otherwise>single;48</xsl:otherwise>
  87.                             </xsl:choose>
  88.                         </xsl:when>
  89.                         <xsl:when test="$border-style = 'double'">
  90.                             <xsl:choose>
  91.                                 <xsl:when test="$border-value < 0.064">double;2</xsl:when>
  92.                                 <xsl:when test="$border-value < 0.098">double;6</xsl:when>
  93.                                 <xsl:when test="$border-value < 0.115">thin-thick-small-gap;12</xsl:when>
  94.                                 <xsl:when test="$border-value < 0.135">thin-thick-large-gap;18</xsl:when>
  95.                                 <xsl:when test="$border-value < 0.168">thick-thin-medium-gap;24</xsl:when>
  96.                                 <xsl:when test="$border-value < 0.190">thin-thick-medium-gap;24</xsl:when>
  97.                                 <xsl:when test="$border-value < 0.221">thin-thick-small-gap;24</xsl:when>
  98.                                 <xsl:when test="$border-value < 0.241">thin-thick-medium-gap;36</xsl:when>
  99.                                 <xsl:when test="$border-value < 0.300">double;18</xsl:when>
  100.                                 <xsl:when test="$border-value < 0.430">
  101.                                     <xsl:variable name="border-inner-line-value">
  102.                                         <xsl:call-template name="convert2cm">
  103.                                             <xsl:with-param name="value" select="$border-line-width"/>
  104.                                         </xsl:call-template>
  105.                                     </xsl:variable>
  106.                                     <xsl:if test="$border-inner-line-value < 0.10">thin-thick-medium-gap;48</xsl:if>
  107.                                     <xsl:if test="$border-inner-line-value > 0.10">double;24</xsl:if>
  108.                                 </xsl:when>
  109.                                 <xsl:otherwise>double;24</xsl:otherwise>
  110.                             </xsl:choose>
  111.                         </xsl:when>
  112.                         <xsl:otherwise>none;0</xsl:otherwise>
  113.                     </xsl:choose>
  114.                 </xsl:variable>
  115.                 <xsl:value-of select="$microsoft-border-style-size"/>
  116.             </xsl:otherwise>
  117.         </xsl:choose>
  118.     </xsl:template>
  119.     <!-- get bottom and right border style, size, color  -->
  120.     <xsl:template name="get-border">
  121.         <xsl:param name="so-border"/>
  122.         <xsl:param name="so-border-line-width"/>
  123.         <xsl:param name="so-border-position"/>
  124.         <xsl:variable name="ms-style-width">
  125.             <xsl:call-template name="get-border-size">
  126.                 <xsl:with-param name="border" select="$so-border"/>
  127.                 <xsl:with-param name="border-line-width" select="$so-border-line-width"/>
  128.             </xsl:call-template>
  129.         </xsl:variable>
  130.         <xsl:choose>
  131.             <xsl:when test="$so-border-position = 'bottom' or $so-border-position = 'right'">
  132.                 <!-- if border style is bottom or right border we need to change the thin-thick to thick-thin; Vice Versa -->
  133.                 <xsl:choose>
  134.                     <xsl:when test="substring-before($ms-style-width, '-')='thin'">
  135.                         <xsl:attribute name="w:val"><xsl:value-of select="concat( 'thick-thin', substring-after(substring-before($ms-style-width, ';'), 'k' ))"/></xsl:attribute>
  136.                     </xsl:when>
  137.                     <xsl:when test="substring-before($ms-style-width, '-')='thick'">
  138.                         <xsl:attribute name="w:val"><xsl:value-of select="concat( 'thin-thick', substring-after(substring-before($ms-style-width, ';'), 'n' ))"/></xsl:attribute>
  139.                     </xsl:when>
  140.                     <xsl:otherwise>
  141.                         <xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width, ';')"/></xsl:attribute>
  142.                     </xsl:otherwise>
  143.                 </xsl:choose>
  144.                 <xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
  145.             </xsl:when>
  146.             <xsl:when test="$so-border-position = 'top' or $so-border-position = 'left'">
  147.                 <xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width,';')"/></xsl:attribute>
  148.                 <xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
  149.             </xsl:when>
  150.         </xsl:choose>
  151.         <!--get border color -->
  152.         <xsl:choose>
  153.             <xsl:when test="contains($so-border,'#')">
  154.                 <xsl:attribute name="w:color"><xsl:value-of select="substring-after($so-border, '#')"/></xsl:attribute>
  155.             </xsl:when>
  156.             <xsl:otherwise>
  157.                 <xsl:attribute name="w:color">auto</xsl:attribute>
  158.             </xsl:otherwise>
  159.         </xsl:choose>
  160.     </xsl:template>
  161. </xsl:stylesheet>
  162.